import cvxopt

# cvxopt.matrix() 列优先
P = cvxopt.matrix([[14., 12., 0.], [12., 21., 4.], [0., 4., 6.]])
q = cvxopt.matrix([-1., -1., -1.])
G = cvxopt.matrix([[-1., 0., 0.], [0., -1., 0.], [0., 0., -1.]])
A = cvxopt.matrix([1., 1., -1], (1, 3))
b = cvxopt.matrix([0.])
h = cvxopt.matrix([0., 0., 0.])

cvxopt.solvers.options['show_progress'] = False
sol = cvxopt.solvers.qp(P=P, q=q, G=G, h=h, A=A, b=b)
x = [i for i in sol['x']]
print('x1=%s\nx2=%s\nx3=%s' % (x[0], x[1], x[2]))
